﻿namespace EventBusNet6
{
    /// <summary>
    /// 返回model
    /// </summary>
    public class ApiResult
    {
        /// <summary>
        /// 状态码
        /// </summary>
        public int Code { get; set; }

        /// <summary>
        /// 内容
        /// </summary>
        public object Data { get; set; }

        /// <summary>
        /// 错误信息
        /// </summary>
        public string Message { get; set; }

    }

    public class FormatterResult
    {
        /// <summary>
        /// 成功
        /// </summary>
        /// <param name="data">返回数据</param>
        /// <returns></returns>
        public static ApiResult Success(object data)
        {
            return new ApiResult { Data = data, Message = null, Code = 0 };
        }
        /// <summary>
        /// 失败
        /// </summary>
        /// <param name="str">错误信息</param>
        /// <param name="code">状态码</param>
        /// <returns></returns>
        public static ApiResult Failed(string str, int code)
        {
            return new ApiResult { Data = null, Message = str, Code = code };
        }
    }

}
